/**
 * 
 */
package com.chinasofti.project.web;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.chinasofti.project.dal.model.BzShippingAddress;
import com.chinasofti.project.service.address.AddressService;
import com.chinasofti.project.web.common.ControllerBase;

/**
 * @author Fanxin
 * @Date2018年9月27日下午4:20:14
 */
public class AddressController extends ControllerBase {
	@Autowired
	private AddressService addressService;

	@RequestMapping("setDefaultAddress")
	public void setDefaultAddress(ModelMap mm, int saId, int saIdDefault, HttpSession hs) {
		BzShippingAddress bzShippingAddressDef = new BzShippingAddress();
		bzShippingAddressDef.setSaId(saIdDefault);
		bzShippingAddressDef.setUserId((int) hs.getAttribute("userId"));
		bzShippingAddressDef.setSaAddressState("N");
		addressService.modifyDefaultAddress(bzShippingAddressDef);
		BzShippingAddress bzShippingAddressNewDef = new BzShippingAddress();
		bzShippingAddressNewDef.setSaId(saIdDefault);
		bzShippingAddressNewDef.setUserId((int) hs.getAttribute("userId"));
		bzShippingAddressNewDef.setSaAddressState("Y");
		addressService.modifyDefaultAddress(bzShippingAddressNewDef);

	}
}
